package entities;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.exception.*;

import com.dao.SearchUsers;
import com.util.*;

import org.hibernate.cfg.Configuration;

import entities.*;
public class hiberateTest {

	public static Users connect()
	{
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		
		SearchUsers u = new SearchUsers();
		
			Session se = sf.openSession();
			if(se.isConnected());
			System.out.println("connected");
			//tran = se.beginTransaction();
			Users user=(Users)se.createQuery("from Users as u where u.email= 'Aliquam@rutrum.co.uk'").uniqueResult();
			return user;
	}
	/*public static void main(String [] args)
	{
		//HbnUtil hu = new HbnUtil();
		Transaction tran = null;
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		
		SearchUsers u = new SearchUsers();
		
			Session se = sf.openSession();
			if(se.isConnected());
			System.out.println("connected");
			//tran = se.beginTransaction();
			Users user=(Users)se.createQuery("from Users as u where u.email= 'Aliquam@rutrum.co.uk'").uniqueResult();
			System.out.println("Username: " + user.getName() + user.getPassword() + user.getPhone());
			//tran.commit();
			se.close();
			
		
		
	}*/
}
